package com.xy.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/*
 * @教材表
 */
@SuppressWarnings("serial")
@Entity
@Table
@Cacheable
public class TextBook extends Identified implements Serializable {

	@Column(nullable = false)
	private String name;// 教材名
	@Column(nullable = false, unique = true)
	private String isbn;// ISBN
	@Column(nullable = false)
	private String author;// 作者
	@Column(nullable = false)
	private String edit;// 版次
	@Column(nullable = false)
	private String publishCompany;// 出版商
	@Column(nullable = false)
	private String punlishTime;// 出版时间
	@Column(nullable = false)
	private double price;// 价格
	private String remark;// 备注

	@ManyToOne(targetEntity = PackageBook.class) // 套书
	@JoinColumn(name = "PackageBook_Id", referencedColumnName = "id")
	private PackageBook packageBook;

	@OneToMany(targetEntity = DeliverToOther.class, mappedBy = "textBook") // 其他人领书
	private Set<DeliverToOther> deliverToOthers = new HashSet<DeliverToOther>();

	@OneToMany(targetEntity = DeliverToTeacher.class, mappedBy = "textBook") // 教师领书
	private Set<DeliverToTeacher> deliverToTeachers = new HashSet<DeliverToTeacher>();

	@OneToMany(targetEntity = DeliverToStation.class, mappedBy = "textBook") // 函授站领书
	private Set<DeliverToStation> deliverToStations = new HashSet<DeliverToStation>();

	@ManyToOne(targetEntity = Cell.class) // 货架
	@JoinColumn(name = "Cell_id", referencedColumnName = "id", nullable = true)
	private Cell cell;

	@OneToMany(targetEntity = StockReceive.class, mappedBy = "textBook") // 教材
	private Set<StockReceive> stockReceives = new HashSet<StockReceive>();

	@OneToMany(targetEntity = StockSelect.class, mappedBy = "textBook") // 库存
	private Set<StockSelect> stockSelects = new HashSet<StockSelect>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIsbn() {
		return isbn;
	}

	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getEdit() {
		return edit;
	}

	public void setEdit(String edit) {
		this.edit = edit;
	}

	public String getPublishCompany() {
		return publishCompany;
	}

	public void setPublishCompany(String publishCompany) {
		this.publishCompany = publishCompany;
	}

	public String getPunlishTime() {
		return punlishTime;
	}

	public void setPunlishTime(String punlishTime) {
		this.punlishTime = punlishTime;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public PackageBook getPackageBook() {
		return packageBook;
	}

	public void setPackageBook(PackageBook packageBook) {
		this.packageBook = packageBook;
	}

	public Set<DeliverToOther> getDeliverToOthers() {
		return deliverToOthers;
	}

	public void setDeliverToOthers(Set<DeliverToOther> deliverToOthers) {
		this.deliverToOthers = deliverToOthers;
	}

	public Set<DeliverToTeacher> getDeliverToTeachers() {
		return deliverToTeachers;
	}

	public void setDeliverToTeachers(Set<DeliverToTeacher> deliverToTeachers) {
		this.deliverToTeachers = deliverToTeachers;
	}

	public Set<DeliverToStation> getDeliverToStations() {
		return deliverToStations;
	}

	public void setDeliverToStations(Set<DeliverToStation> deliverToStations) {
		this.deliverToStations = deliverToStations;
	}

	public Cell getCell() {
		return cell;
	}

	public void setCell(Cell cell) {
		this.cell = cell;
	}

	public Set<StockReceive> getStockReceives() {
		return stockReceives;
	}

	public void setStockReceives(Set<StockReceive> stockReceives) {
		this.stockReceives = stockReceives;
	}

	public Set<StockSelect> getStockSelects() {
		return stockSelects;
	}

	public void setStockSelects(Set<StockSelect> stockSelects) {
		this.stockSelects = stockSelects;
	}

	public TextBook() {
		super();
		// TODO Auto-generated constructor stub
	}

}
